﻿using System;
using Plugins.Core;

namespace Plugins.Library
{
    public static class PluginHelper
    {
        public static bool Execute<T>(T obj, Action<T> action)
        {
            if (!object.Equals(obj, default(T)) && action != null)
            {
                action(obj);
                return true;
            }
            return false;
        }

        public static bool GetInvocationList(EventHandler<PluginEventArgs> source, EventHandler<PluginEventArgs> value)
        {
            return PluginEventHelper.FindDelegate(source, value);
        }

        public static bool GetInvocationList(EventHandler<PluginHostEventArgs> source, EventHandler<PluginHostEventArgs> value)
        {
            return PluginEventHelper.FindDelegate(source, value);
        }

    }
}
